#!/bin/sh

set -e

if [ $# -ne 1 ]
then
    echo "usage: set_version version" >& 2
    exit 2
fi

version="$1"
short_version=`expr "$version" : '\([^.]*\.[^.]*\)'`

ed_version() {
    ed "$1" <<!
/$2/s/=[^=]*$/= $3/
w
q
!
}

ed_version setup.py version "'$version',"
ed_version ot_simulator/__init__.py version "'$version'"
ed_version scripts/svg2csv.py version "'%prog $version',"
ed_version scripts/offset_template.py version "'%prog $version')"
ed_version tools/show_rosette.py version "'%prog $version')"
ed_version tools/make_template.py version "'%prog $version')"
ed_version doc/sphinx/source/conf.py ^version "'$short_version'"
ed_version doc/sphinx/source/conf.py ^release "'$version'"

echo $version > version
